﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using App1AppHandler;

namespace Reborn_WorldServer.App1AppHandler
{
    public class PendingTeleportRequest : PendingUserInput
    {
        private int mapId;
        private int mapX;
        private int mapY;

        public PendingTeleportRequest(Character character, int mapId, int mapX, int mapY, string message)
            : base(character)
        {
            this.mapId = mapId;
            this.mapX = mapX;
            this.mapY = mapY;

            List<string> choices = new List<string>();
            choices.Add("Yes");
            choices.Add("No");

            base.sendRequest(new PendingUserInputData("Teleport", message, choices, "No"));
            base.startExpireTimer(15000);
        }

        public override bool processResult(string choice)
        {
            if (base.processResult(choice) == false || choice == "No")
                return false;

            Managers.GameHandler.Teleport(parentCharacter, mapId, mapX, mapY, preServerTransferMethod);

            return true;
        }

        private void preServerTransferMethod()
        {
            //Try to stop the round timer, this will only return true, if it was running, and was stopped
            //This means they are perma busy until they hit the other server,
            //If we return false, they are not busy due to lag or something, set them busy before transfer.
            if (parentCharacter.tryStopRoundTimer() == false)
                parentCharacter.SetBusy(true);
        }
    }
}
